﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BaseSomeDemos
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            ////事件拥有者和响应者不相同
            //Application.Run(new Form1());
            ////事件拥有者和事件响应者是相同的
            //Application.Run(new Form2());
            ////事件响应者为事件的字段成员
            Application.Run(new EventDemo3());
        }
    }

    class Controller
    {
        private EventDemo1 form1;
        public Controller(EventDemo1 form)
        {
            if (form != null)
            {
                this.form1 = form;
                this.form1.Click += this.FormClick;
            }
        }

        private void FormClick(object sender, EventArgs e)
        {
            this.form1.Text = DateTime.Now.ToString();
        }
    }
}
